package com.tianpengtech.common.search;

import java.util.ArrayList;
import java.util.List;

public class InCondition extends Condition{

	public InCondition(String fieldName, Object value) {
        this.filedName = fieldName;
        this.value = value;
    }
	
	@Override
	public String buildSQL() {
		List<Object> values = (List)this.value;
		this.sqlBuffer.append(" ").append(this.filedName).append(" in (");
		for (int i=0;i<=values.size();i++) {
			this.sqlBuffer.append(" ? ");
			if(i!=values.size()){
				this.sqlBuffer.append(" , ");
			}
		}
		this.sqlBuffer.append(" ").append(" )");
		return this.sqlBuffer.toString();
	}

	
	public static void main(String[] args) {
		QueryConstructor q = new QueryConstructor();
		List<Object> params = new ArrayList<Object>();
		params.add(1234);
		params.add(1234);
		params.add(1234);
		q.and(new InCondition("test", params));
		String sql = q.buildSQL();
		System.out.println(sql);
	}
}
